# -*- coding: utf-8 -*-

def main(n):
    s = 0
    for x in range(1,n):
        for y in range(x,n):
            ss = x + y
            if ss == n:
                print x,y
                s = s + 1

    for x in range(1,n):
        for y in range(x,n):
            for z in range(y,n):
                ss = x + y + z
                if ss == n:
                    print x,y,z
                    s = s + 1

    for x in range(1,n):
        for y in range(x,n):
            for z in range(y,n):
                for xx in range(z,n):
                    ss = x + y + z + xx
                    if ss == n:
                        print x,y,z,xx
                        s = s + 1
    for x in range(1,n):
        for y in range(x,n):
            for z in range(y,n):
                for xx in range(z,n):
                     for yy in range(xx,n):
                        ss = x + y + z + xx + yy
                        if ss == n:
                            print x,y,z,xx,yy
                            s = s + 1
    for x in range(1,n):
        for y in range(x,n):
            for z in range(y,n):
                for xx in range(z,n):
                     for yy in range(xx,n):
                        for zz in range(yy,n):
                            ss = x + y + z + xx + yy + zz
                            if ss == n:
                                print x,y,z,xx,yy,zz
                                s = s + 1
    for x in range(1,n):
        for y in range(x,n):
            for z in range(y,n):
                for xx in range(z,n):
                     for yy in range(xx,n):
                        for zz in range(yy,n):
                            for xxx in range(zz,n):
                                ss = x + y + z + xx + yy + zz + xxx
                                if ss == n:
                                    print x,y,z,xx,yy,zz,xxx
                                    s = s + 1
    print n,u'合计:',s

def jianhua(n):
    s = 0
    for x in range(1,n):
        for y in range(x,n):
            if x + y == n:
                print x,y
                s = s + 1
                break
            for z in range(y,n):
                if x + y +z == n:
                    print x,y,z
                    s = s + 1
                    break
                for xx in range(z,n):
                    if x + y +z  + xx== n:
                        print x,y,z,xx
                        s = s + 1
                        break
                    for yy in range(xx,n):
                        if x + y +z  + xx + yy== n:
                            print x,y,z,xx,yy
                            s = s + 1
                            break
                        for zz in range(yy,n):
                            if x + y +z  + xx + yy + zz== n:
                                print x,y,z,xx,yy,zz
                                s = s + 1
                                break
                            for xxx in range(zz,n):
                                if x + y + z + xx + yy + zz + xxx == n:
                                    print x,y,z,xx,yy,zz,xxx
                                    s = s + 1
                                    break
    print n,u'合计:',s

if __name__ == '__main__':
##    main(7)
##    print
    jianhua(5)









